//
//  WoDeFenSiTuanTableViewController.m
//  1243
//
//  Created by 袖手旁觀 on 16/4/7.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "WoDeFenSiTuanTableViewController.h"
#import "NetWorkTools.h"
#import "ReadLoginData.h"

@interface WoDeFenSiTuanTableViewController ()

@property (nonatomic,strong)NSArray *array;

@property (nonatomic,strong)NSArray *dataArray;

@property (nonatomic,strong)NSDictionary *MyFansData;

@end

@implementation WoDeFenSiTuanTableViewController

- (NSArray *)array {
    if (!_array) {
        _array = @[@"粉丝数",@"购买单数",@"今日单数",@"粉丝团单数",@"今日粉丝团单数"];
        
    }
    return _array;
}

- (NSArray *)dataArray {
    if (!_dataArray) {
        _dataArray = @[@"FansNumer",@"ByOrders",@"TodayByOrders",@"FansGroupOrders",@"TodayFansGroupOrders"];
    }
    return _dataArray;
}

//- (NSDictionary *)MyFansData {
//    if (_MyFansData) {
//        _MyFansData = [NSDictionary dictionary];
//    }
//    return _MyFansData;
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView = [[UIView alloc] init];
    
    [self loadFenSiTuanData];
    
    self.title = @"我的粉丝团";
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.array.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    cell.textLabel.text = self.array[indexPath.row];
    if ([self.MyFansData objectForKey:self.dataArray[indexPath.row]]) {
        cell.detailTextLabel.text = [self.MyFansData objectForKey:self.dataArray [indexPath.row]];
    } else {
        cell.detailTextLabel.text = @"0";
    }
    
   
    
    NSLog(@"%@",self.MyFansData);
    NSLog(@"%@",self.dataArray);
    
    NSString *string = self.dataArray[indexPath.row];
    
    NSLog(@"%@",[self.MyFansData objectForKey:string]);
    return cell;
}

- (void)loadFenSiTuanData {
    NSDictionary *dict = [ReadLoginData readLoginData];
    
    NSDictionary *params = @{
                             @"UserId":[NSString stringWithFormat:@"%@",[dict objectForKey:@"Number"]]
//                             @"UserId":@"1001"
                             };
    
    [[NetWorkTools sharedNetWorkTools] objectWithURLDict: params AndMenthodName:@"GETMYFANSGROUP" completeBlock:^(id object) {
        
        
//        self.MyFansData = [NetWorkTools dictionaryWithJsonString:[object objectForKey:@"BackData"]];
        NSString *string = [object objectForKey:@"BackData"];
        
        NSLog(@"%@",[NetWorkTools dictionaryWithJsonString:string]);
        
        self.MyFansData = [NetWorkTools dictionaryWithJsonString:string];
        
        NSLog(@"%@",self.MyFansData);
        
        
        
        [self.tableView reloadData];
    }];
}

@end